67e19361f31e274323c3e809a6e5cf1b28d24a24,src/test/java/com/stewsters/test/examples/chunk/OverworldPathfinder.java,OverworldPathfinder,getPath,#OverworldExample#number#number#number#number#Mover2dV2#number#,14
Before Change
int preciseDestinationY = globalDestinationY % Chunk.ySize;
Chunk sourceChunk = overworld.getChunk(globalStartingX, globalStartingY);
int sourceRegionId = sourceChunk.regionIds[preciseStartingX][preciseStartingY];
Chunk destinationChunk = overworld.getChunk(globalDestinationX, globalDestinationY);
int destinationRegionId = destinationChunk.regionIds[preciseDestinationX][preciseDestinationY];
OverworldPathNode startingNode = new OverworldPathNode(sourceChunk, preciseStartingX, preciseStartingY);
OverworldPathNode destinationNode = new OverworldPathNode(destinationChunk, preciseDestinationX, preciseDestinationY);
// Add edges
for (OverworldPathNode overworldPathNode : sourceChunk.overworldPathNodes) {
if (sourceChunk.regionIds[overworldPathNode.getPreciseX()][overworldPathNode.getPreciseY()] == sourceRegionId) {
new OverworldEdge(startingNode, overworldPathNode, 1);
}
}
After Change
int preciseDestinationX = globalDestinationX % ExampleChunk.xSize;
int preciseDestinationY = globalDestinationY % ExampleChunk.ySize;
ExampleChunk sourceChunk = overworld.getChunk(globalStartingX, globalStartingY);
int sourceRegionId = sourceChunk.getRegionId(preciseStartingX, preciseStartingY);
ExampleChunk destinationChunk = overworld.getChunk(globalDestinationX, globalDestinationY);
int destinationRegionId = destinationChunk.getRegionId(preciseDestinationX, preciseDestinationY);
OverworldPathNode startingNode = new OverworldPathNode(sourceChunk, preciseStartingX, preciseStartingY);
OverworldPathNode destinationNode = new OverworldPathNode(destinationChunk, preciseDestinationX, preciseDestinationY);
// Add edges
for (OverworldPathNode overworldPathNode : sourceChunk.overworldPathNodes) {
if (sourceChunk.getRegionId(overworldPathNode.getPreciseX(), overworldPathNode.getPreciseY()) == sourceRegionId) {
new OverworldEdge(startingNode, overworldPathNode, 1);
}
}